<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>设置/获取所有 bc math 函数的默认小数点保留位数</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.bcpowmod.html">« bcpowmod</a></li>
      <li style="float: right;"><a href="function.bcsqrt.html">bcsqrt »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.bc.html">BC 数学 函数</a></li>
    <li>设置/获取所有 bc math 函数的默认小数点保留位数</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.bcscale" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">bcscale</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">bcscale</span> &mdash; <span class="dc-title">设置/获取所有 bc math 函数的默认小数点保留位数</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.bcscale-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>bcscale</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$scale</code></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   设置所有 bc math 函数在未设定情况下的小数点保留位数。
  </p>
  <div class="methodsynopsis dc-description"><span class="methodname"><strong>bcscale</strong></span>(<span class="methodparam"><span class="type">null</span> <code class="parameter">$scale</code><span class="initializer"> = <strong><code>null</code></strong></span></span>): <span class="type">int</span></div>

  <p class="para rdfs-comment">
   获取当前的小数点保留位数。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.bcscale-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">scale</code></dt>

     <dd>

      <p class="para">
       小数点保留位数。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.bcscale-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   设置的时候，返回之前的小数点保留位数。否则就是返回当前的位数。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.bcscale-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       现在 <code class="parameter">scale</code> 可以为 null。
      </td>
     </tr>

     <tr>
      <td>7.3.0</td>
      <td>
       现在 <span class="function"><strong>bcscale()</strong></span> 不仅可以设置，还可以获取当前的小数点保留位数。
       用于设置的时候，现在会返回之前的位数。
       之前 <code class="parameter">scale</code> 是强制的参数， 且
       <span class="function"><strong>bcscale()</strong></span> 总是返回 <strong><code>true</code></strong>。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>

 
 <div class="refsect1 examples" id="refsect1-function.bcscale-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3030">
    <p><strong>示例 #1 <span class="function"><strong>bcscale()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;默认小数点位数：&nbsp;3<br /></span><span style="color: #0000BB">bcscale</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #0000BB">bcdiv</span><span style="color: #007700">(</span><span style="color: #DD0000">'105'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'6.55957'</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;16.007<br /><br />//&nbsp;不调用&nbsp;bcscale()&nbsp;也一样<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">bcdiv</span><span style="color: #007700">(</span><span style="color: #DD0000">'105'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'6.55957'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;16.007<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

</div></div></div></body></html>